

#include "combat.h"
#include "ftechinfo.h"

void SimpleDD(Creature &p1, Creature &p2)
{


    int D20 = 20;
    srand(time(NULL));
    int hit_flag;
    int damage;
    int initflag = CmpInit();

    if (initflag == 1)
    {
        hit_flag = rand() % D20;
        if (hit_flag >= p2.Tohit)
        {
            damage = rand() % p1.Str;
            p2.DamRecieve(damage);
            AddBLog("You " + p1.GetHitType(S_1H_SWORD) +
		" moster on " + its(damage) + " damage.\n");
        } else
        {
            AddBLog("You miss\n");
        }

    } else

    {
        if (hit_flag >= p1.Tohit)
        {
            damage = rand() % p2.Str;
            p1.DamRecieve(damage);

            AddBLog("Mob hit you on on " + its(damage) + " damage.\n");
        } else
        {
            AddBLog("it's missed you.\n");
        }


    }



};

int CmpInit()
{
    srand(time(NULL));

    int Initiative[2];
    //Initiative dice
    for (int i = 0; i < 2; i++)
    {
        Initiative[i] = rand() % 20;
    }

    if (Initiative[0] >= Initiative[1])
    {

        return 1;
    } else
    {

        return 2;
    }
};